feat(auth): request offline_access scope in device flow#21
Merged
Conversation
Without `offline_access` in the device-authz scope param, Keycloak issues a refresh token bound to the SSO session-idle window (realm default 30 minutes). After a short idle period the CLI's next refresh fails and `FileTokenSource` deletes the credentials, forcing a `grounds login` re-auth — a bad UX for an interactive CLI. Adding `offline_access` upgrades the refresh token to an offline token whose lifetime is governed by the offline-session settings (default 30 days), matching the behaviour every developer expects from `gh`, `kubectl oidc-login`, etc. Verified live: same client + same user - scope=openid → refresh_expires_in=1800 - scope=openid offline_access → refresh_expires_in=0 (offline) `offline_access` is a default optional realm scope in Keycloak, so no per-client wiring is needed in keycloak-clients.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
offline_accessto the scope param in the device-authz request so Keycloak issues an offline refresh token instead of a session-idle-bound one.grounds loginagain. Same UX broke for me today; this is the fixgh,kubectl oidc-login, etc. all use.Verification
Live test against
account.grounds.gg/realms/groundswith the same client + same user:refresh_expires_inopenidopenid offline_accessoffline_accessis a default optional realm scope in Keycloak — nokeycloak-clients.tschange needed.Test plan
go test ./internal/auth/...— passes (new assertion that scope containsoffline_access)go vet ./...cleanbrew upgrade grounds && grounds loginshould survive a >30min idle🤖 Generated with Claude Code